/*
 * @lc app=leetcode.cn id=875 lang=javascript
 *
 * [875] 爱吃香蕉的珂珂
 */

// @lc code=start
/**
 * @param {number[]} piles
 * @param {number} h
 * @return {number}
 */
var minEatingSpeed = function (piles, h) {
  let check = () => {
    let sum = 0;
    for (let i = 0; i < dist.length; i++) {
      if (i !== dist.length - 1) {
        sum += Math.ceil(dist[i] / ans);
      } else sum += dist[i] / ans;
    }
    return sum <= hour;
  };
  let l = 0;
  let r = piles.length - 1;
  while (l < r) {
    let mid = l + (r - l) / 2;
    if (check(mid)) {
      l = mid;
    } else {
      r = mid;
    }
  }
};
// @lc code=end
